package ui;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.ImageIcon;
import javax.swing.JComboBox;

import resourse.ResourseMannager;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JLabel;
import javax.swing.JTextField;


/**
 * 
 * @author ganlinux
 * 
 * 
 */
public class SettingConfigPanel extends javax.swing.JPanel {
	//EIMDesktop desktop=null;
	String imageName=null;
    public SettingConfigPanel() {
    	//desktop=EIMDesktop.getInstance();
        initComponents();
    }
    private void initComponents() {
        resetButton = new javax.swing.JButton();
        useButton = new javax.swing.JButton();
      
        if(imageName==null){
        	//imageName=desktop.getDeskTopConfig().getWallPaper();
        	if(imageName==null){
        	imageName="Bliss.jpg";
        	}
        }
        ImageIcon icon=ResourseMannager.getImageIcon(imageName, 279, 194);
        String[] iamgeNames=ResourseMannager.getWallImageNames();

        resetButton.setText("\u53d6\u6d88");
        resetButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                resetButtonMouseClicked(evt);
            }
        });

        useButton.setText("\u5e94\u7528");
        useButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                useButtonMouseClicked(evt);
            }
        });
        
        JLabel label = new JLabel("监听端口：");
        
        textField = new JTextField();
        textField.setColumns(10);
        
        textField_1 = new JTextField();
        textField_1.setColumns(10);
        
        label_1 = new JLabel("心跳间隔：");
        
        label_2 = new JLabel("秒");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        layout.setHorizontalGroup(
        	layout.createParallelGroup(Alignment.LEADING)
        		.addGroup(layout.createSequentialGroup()
        			.addGap(161)
        			.addComponent(resetButton)
        			.addGap(18)
        			.addComponent(useButton)
        			.addContainerGap(157, Short.MAX_VALUE))
        		.addGroup(Alignment.TRAILING, layout.createSequentialGroup()
        			.addGap(121)
        			.addGroup(layout.createParallelGroup(Alignment.TRAILING)
        				.addComponent(label_1, GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)
        				.addComponent(label, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        			.addGap(72)
        			.addGroup(layout.createParallelGroup(Alignment.TRAILING)
        				.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        				.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addComponent(label_2)
        			.addGap(115))
        );
        layout.setVerticalGroup(
        	layout.createParallelGroup(Alignment.TRAILING)
        		.addGroup(layout.createSequentialGroup()
        			.addContainerGap(90, Short.MAX_VALUE)
        			.addGroup(layout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        				.addComponent(label))
        			.addGap(26)
        			.addGroup(layout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        				.addComponent(label_2)
        				.addComponent(label_1))
        			.addGap(87)
        			.addGroup(layout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(resetButton)
        				.addComponent(useButton))
        			.addGap(32))
        );
        this.setLayout(layout);
    }

    private void useButtonMouseClicked(java.awt.event.MouseEvent evt) {
    	//String newName="wallimage/"+(String)(jComboBox1.getSelectedItem());
    	//PropertyFrame.getInstance().setVisible(false);
    	//EIMDesktop desktop=EIMDesktop.getInstance();
    	//desktop.intWallPaper(newName);
    	//DeskTopConfig deskTopConfig =desktop.getDeskTopConfig();
    	//deskTopConfig.setWallPaper(newName);
    	//ServerUtils.writeDeskTopConfig(deskTopConfig);
    	//imageName=newName;
    	//System.out.println(newName);
    	
    }

    private void resetButtonMouseClicked(java.awt.event.MouseEvent evt) {
    	//desktop.intWallPaper(imageName);
    	//desktop.repaint();
    	//PropertyFrame.getInstance().setVisible(false);
    }
    private javax.swing.JButton resetButton;
    private javax.swing.JButton useButton;
    private JTextField textField;
    private JTextField textField_1;
    private JLabel label_1;
    private JLabel label_2;
}